package com.wondersgroup.framework.sample.component.form.action;

import com.wondersgroup.framework.core.web.struts2.action.BaseAjaxAction;
import com.wondersgroup.framework.core.web.vo.VOUtils;
import com.wondersgroup.framework.sample.component.form.vo.MenuItem;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import net.sf.json.JSONObject;
import org.apache.commons.logging.Log;

public class OutlookAction extends BaseAjaxAction
{
  public String load()
  {
    List result = new ArrayList();
    HashMap outlookMenu = new HashMap();
    HashMap outlookMenu2 = new HashMap();

    String[] channel = { "表单", "信息管理", "表格", "树" };
    String[] program1 = { "高级表单" };
    String[] program2 = { "信息登记", "信息修改", "信息查询" };
    String[] program3 = { "表格编辑" };
    String[] program4 = { "编辑树", "树状表格" };
    String[][] url7 = { { "../form/form/form.jsp" }, { "../../combination/form_fieldset/inforegister.jsp", "../../combination/form_tabs/formLoad.jsp", "../../combination/form_grid/personInfo.jsp" }, { "../grid/editGrid/editGrid.jsp" }, { "../../combination/tree_form/treeForm.jsp", "../grid/treeGrid/treeGrid.jsp" } };

    String[][] url8 = { { "hot1.gif" }, { "i_new.gif", "new(1).gif", "new2.gif" }, { "new3.gif" }, { "new4.gif", "con2.gif" } };

    outlookMenu.put(channel[0], program1);
    outlookMenu.put(channel[1], program2);
    outlookMenu.put(channel[2], program3);
    outlookMenu.put(channel[3], program4);

    for (int i = 0; i < 4; ++i) {
      MenuItem banItem = new MenuItem();
      banItem.setId(String.valueOf(i + 1));
      banItem.setName(channel[i]);

      JSONObject jsonObject = JSONObject.fromObject(banItem);
      String[] program = (String[])outlookMenu.get(channel[i]);
      List childList = new ArrayList();
      for (int j = 0; j < program.length; ++j) {
        MenuItem detailItem = new MenuItem();
        detailItem.setId(banItem.getId() + "-" + String.valueOf(j));
        detailItem.setUrl(url7[i][j]);
        detailItem.setIcon(url8[i][j]);

        detailItem.setName(program[j]);

        childList.add(detailItem);
      }

      jsonObject.put("childMenu", childList);
      result.add(jsonObject);
    }
    String json = VOUtils.getJsonDataFromCollection(result);
    createJSonData(json);
    this.logger.info("OutlookMenuItem加载");
    return "ajax";
  }
}